package cn.lili.modules.distribution.mapper;

import cn.lili.modules.distribution.entity.dos.Distribution;
import cn.lili.modules.distribution.entity.dto.DistributionSearchParams;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;


/**
 * 分销员数据处理层
 *
 * @author pikachu
 * @since 2020-03-14 23:04:56
 */
public interface DistributionMapper extends BaseMapper<Distribution> {

    /**
     * 添加分销金额
     *
     * @param commissionFrozen 分销金额
     * @param distributionId   分销员ID
     */
    @Update("UPDATE li_distribution set rebate_total=(rebate_total+#{rebate_total}) " +
            ", distribution_order_count=(distribution_order_count+1) WHERE id = #{distributionId}")
    void addCommission(Double commissionFrozen, String distributionId);


    /**
     * 查询店主列表,包含所在工会名称信息,及下级人数
     */
    Page<Distribution> queryDistributionPage1(Page<Distribution> page, @Param("dis") DistributionSearchParams distributionSearchParams);
    //查询直推佣金和间推佣金
    List<Distribution> getLowerAndLowerComissSubByParentId(@Param("parentId") String parentId, @Param("flowTime") String flowTime, @Param("profitSharing") String profitSharing, @Param("nickName") String nickName);
}